
<template>
  <div>
    <a-modal v-model="visible" centered :title="title" width="800px" @cancel="close" :destroyOnClose="true">
      <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-form-model-item ref="name" label="发布方名称" prop="name">
          <a-input
            v-model="form.name"
            @blur="
              () => {
                $refs.name.onFieldBlur()
              }
            "
          />
        </a-form-model-item>
        <a-form-model-item label="备注">
          <a-input v-model="form.resource" />
        </a-form-model-item>
        <a-form-model-item label="头像">
          <JImageUpload :uploadParams="getUploadParams()" :isMultiple="false" :accept="'image/*'" @fileChange="fileChange" v-model="imgList"></JImageUpload>
        </a-form-model-item>
      </a-form-model>
    </a-modal>
  </div>
</template>
<script>
import JImageUpload from '@/components/qiniuUpload/JImageUpload.vue'
import globalData from '@/assets/js/common'
export default {
  components: {
    JImageUpload
  },
  data() {
    return {
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      visible: false,
      form: {
        name: '',
        resource: '',
        desc: '',
        imgList: []
      },
      imgList: [],
      title: '',
      rules: {
        name: [{ required: true, message: '请填写名称', trigger: 'blur' }]
      }
    }
  },
  methods: {
    // 上传图片
    getUploadParams() {
      return { ...globalData.uploadParams }
    },
    fileChange(list) {
      this.form.imgList = list[0].url
    },
    close() {},
    show(id) {
      console.log(id)
      this.title = id == 'add' ? '新增' : '编辑'
      this.visible = true
    }
  }
}
</script>
      
      <style>
</style>